package cn.hr.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import cn.hr.pojo.PayrollCrew;
import cn.hr.utils.Constants;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import cn.hr.dao.mapper.SalProStanMapper;
import cn.hr.pojo.SalProStan;
import cn.hr.service.SalProStanService;

/**
 * 薪酬标准与薪酬项目关系服务接口实现类
 *
 * @author MO
 */
@CacheConfig(cacheNames = "salProStan")
@Scope("prototype")
@Service("salProStanService")
public class SalProStanServiceImpl implements SalProStanService {
    @Resource
    private SalProStanMapper salProStanMapper;

    @Override
    public boolean insert(SalProStan t) throws Exception {
        t.setCreatedDate(new Date());
        return salProStanMapper.insert(t) == 1;
    }

    @Override
    public boolean update(SalProStan t) throws Exception {
        t.setModifyDate(new Date());
        return salProStanMapper.update(t) == 1;
    }

    @Override
    public boolean delete(Integer id) throws Exception {
        return salProStanMapper.delete(id) == 1;
    }

    @Override
    public SalProStan get(Integer id) throws Exception {
        return salProStanMapper.get(id);
    }

    @Override
    public PageInfo<Map> findListByCondition(Map m, int pageNo) throws Exception {
        PageHelper.startPage(pageNo, Constants.PAGESIZE);
        List<Map> list = salProStanMapper.findListByCondition(m);
        return new PageInfo<Map>(list);
    }

    @Override
    public Long findCountByCondition(Map m) throws Exception {
        return salProStanMapper.findCountByCondition(m);
    }

}
